Quasi-Patterns and Programming Strategies
Design Patterns vs. Idiomatic Solutions
-
Design Patterns are general, reusable solutions to common problems in software design that can be applied in many different situations or languages. They often come with well-defined structures and names (e.g., Singleton, Observer, Strategy), facilitating communication among developers.
-
Idiomatic Solutions or Quasi-Patterns tend to be more language-specific or situational. They include optimizations, syntactic conveniences, or particular ways of structuring code that are discovered through practice and experience. They might not have formalized names or structures and can vary widely between programming communities.
Documenting Emerging Patterns
Some processes/idea for filling out this section
Pattern Identification: Start by identifying recurring solutions or strategies that you or others use to solve specific types of problems. This can be through personal coding experience, reading code, or participating in developer forums.
Categorization: Try to categorize these patterns based on their purpose (e.g., performance optimization, error handling, data manipulation). This helps in organizing your documentation and making it more accessible.
Examples and Use Cases: Provide concrete examples and use cases for each pattern. This not only helps in understanding the pattern itself but also when and how to use it effectively.
Comparison with Traditional Patterns: Where relevant, compare and contrast these quasi-patterns with traditional design patterns. This can provide insights into their unique advantages and limitations.
Basic List
-
Branchless Programming: This approach aims to minimize or eliminate branches (e.g., if-else structures) in critical sections of code to improve performance, especially in tight loops or performance-critical sections, by reducing pipeline stalls in CPU execution.
-
Loop Unrolling: This involves expanding a loop into a series of repeated operations to reduce loop overhead and improve cache performance, at the cost of increased code size.
-
Monads: In functional programming, monads provide a way to encapsulate computations and side effects, allowing for a more functional style of error handling, asynchronous operations, and state management, among other things.
-
Ternary Operators and Null Coalescing: The use of ternary operators or null coalescing patterns can streamline conditional logic, making code more concise and sometimes more readable.